package com.biodiv.community.config;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import com.biodiv.community.properties.AliyunOssProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: tianquan
 * @date: 2025-06-28  19:53
 * @description: TODO
 */
@Configuration
public class OssConfig {

    @Autowired
    private AliyunOssProperties aliyunOssProperties;

    @Bean
    public IAcsClient client() {
        String accessKeyId = aliyunOssProperties.getAccessKeyId();
        String region = aliyunOssProperties.getRegion();
        String accessKeySecret = aliyunOssProperties.getAccessKeySecret();

        // 配置区域
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
        return new DefaultAcsClient(profile);

    }


}
